home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
man
/
cat.3
/
libppm.3
< prev
next >
Wrap
Text File
|
1995-07-25
|
7KB
|
199 lines
lllliiiibbbbppppppppmmmm((((3333)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV lllliiiibbbbppppppppmmmm((((3333))))
NNNNAAAAMMMMEEEE
libppm - functions to support portable pixmap programs
SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
#include <ppm.h>
cc ... libppm.a libpgm.a libpbm.a
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
TTTTYYYYPPPPEEEESSSS AAAANNNNDDDD CCCCOOOONNNNSSSSTTTTAAAANNNNTTTTSSSS
typedef ... pixel;
typedef ... pixval;
#define PPM_MAXMAXVAL ...
extern pixval ppm_pbmmaxval;
Each ppppiiiixxxxeeeellll contains three ppppiiiixxxxvvvvaaaalllls, each of which should
contain only the values between 0000 and PPPPPPPPMMMM____MMMMAAAAXXXXMMMMAAAAXXXXVVVVAAAALLLL.
ppppppppmmmm____ppppbbbbmmmmmmmmaaaaxxxxvvvvaaaallll is the maxval used when a PPM program reads a
PBM file. Normally it is 1; however, for some programs, a
larger value gives better results.
#define PPM_FORMAT ...
#define RPPM_FORMAT ...
#define PPM_TYPE PPM_FORMAT
int PPM_FORMAT_TYPE( int format )
For distinguishing different file formats and types.
pixval PPM_GETR( pixel p )
pixval PPM_GETG( pixel p )
pixval PPM_GETB( pixel p )
These three macros retrieve the red, green or blue value
from the given pixel.
void PPM_ASSIGN( pixel p, pixval red, pixval grn, pixval blu )
This macro assigns the given red, green and blue values to
the pixel.
int PPM_EQUAL( pixel p, pixel q )
This macro checks two pixels for equality.
void PPM_DEPTH( pixel newp, pixel p, pixval oldmaxval, pixval newmaxval )
This macro scales the colors of pixel pppp according the old
and new maximum values and assigns the new values to nnnneeeewwwwpppp.
It is intended to make writing ppmtowhatever easier.
float PPM_LUMIN( pixel p )
Page 1 (printed 7/10/95)
lllliiiibbbbppppppppmmmm((((3333)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV lllliiiibbbbppppppppmmmm((((3333))))
This macro determines the luminance of the pixel pppp.
MMMMEEEEMMMMOOOORRRRYYYY MMMMAAAANNNNAAAAGGGGEEEEMMMMEEEENNNNTTTT
pixel** ppm_allocarray( int cols, int rows )
Allocate an array of pixels.
pixel* ppm_allocrow( int cols )
Allocate a row of the given number of pixels.
void ppm_freearray( pixel** pixels, int rows )
Free the array allocated with ppppppppmmmm____aaaallllllllooooccccaaaarrrrrrrraaaayyyy(((()))) containing
the given number of rows.
void pbm_freerow( pixel* pixelrow )
Free a row of pixels.
RRRREEEEAAAADDDDIIIINNNNGGGG PPPPBBBBMMMM FFFFIIIILLLLEEEESSSS
void ppm_readppminit( FILE* fp, int* colsP, int* rowsP, pixval* maxvalP, int* formatP )
Read the header from a PPM file, filling in the rows, cols,
maxval and format variables.
void ppm_readppmrow( FILE* fp, pixel* pixelrow, int cols, pixval maxval, int format )
Read a row of pixels into the pixelrow array. Format, cols,
and maxval were filled in by ppppppppmmmm____rrrreeeeaaaaddddppppppppmmmmiiiinnnniiiitttt(((()))).
pixel** ppm_readppm( FILE* fp, int* colsP, int* rowsP, pixval* maxvalP )
Read an entire pixmap file into memory, returning the
allocated array and filling in the rows, cols and maxval
variables. This function combines ppppppppmmmm____rrrreeeeaaaaddddppppppppmmmmiiiinnnniiiitttt(((()))),
ppppppppmmmm____aaaallllllllooooccccaaaarrrrrrrraaaayyyy(((()))) and ppppppppmmmm____rrrreeeeaaaaddddppppppppmmmmrrrroooowwww(((()))).
WWWWRRRRIIIITTTTIIIINNNNGGGG FFFFIIIILLLLEEEESSSS
void ppm_writeppminit( FILE* fp, int cols, int rows, pixval maxval, int forceplain )
Write the header for a portable pixmap file. The forceplain
flag forces a plain-format file to be written, as opposed to
a raw-format one.
void ppm_writeppmrow( FILE* fp, pixel* pixelrow, int cols, pixval maxval, int forceplain )
Write a row from a portable pixmap.
void ppm_writeppm( FILE* fp, pixel** pixels, int cols, int rows, pixval maxval, int forceplain )
Write the header and all data for a portable pixmap. This
Page 2 (printed 7/10/95)
lllliiiibbbbppppppppmmmm((((3333)))) UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV lllliiiibbbbppppppppmmmm((((3333))))
function combines ppppppppmmmm____wwwwrrrriiiitttteeeeppppppppmmmmiiiinnnniiiitttt(((()))) and ppppppppmmmm____wwwwrrrriiiitttteeeeppppppppmmmmrrrroooowwww(((()))).
CCCCOOOOLLLLOOOORRRR NNNNAAAAMMMMEEEESSSS
pixel ppm_parsecolor( char* colorname, pixval maxval )
Parses an ASCII color name into a pixel. The color can be
specified in three ways. One, as a name, assuming that a
pointer to an X11-style color names file was compiled in.
Two, as an X11-style hexadecimal number: #rgb, #rrggbb,
#rrrgggbbb, or #rrrrggggbbbb. Three, as a triplet of
decimal floating point numbers separated by commas:
r.r,g.g,b.b.
char* ppm_colorname( pixel* colorP, pixval maxval, int hexok )
Returns a pointer to a string describing the given color.
If the X11 color names file is available and the color
appears in it, that name is returned. Otherwise, if the
hexok flag is true then a hexadecimal colorspec is returned;
if hexok is false and the X11 color names file is available,
then the closest matching color is returned; otherwise, it's
an error.
SSSSEEEEEEEE AAAALLLLSSSSOOOO
pbm(3), pgm(3)
AAAAUUUUTTTTHHHHOOOORRRR
Copyright (C) 1989, 1991 by Tony Hansen and Jef Poskanzer.
Page 3 (printed 7/10/95)